package example.io;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class FileExample {

	public static void main(String[] args) {
		File file = new File("d:/vijay.txt");
		try {
			boolean ret = file.createNewFile();
			if (true == ret) {
				System.out.println("File created successfully");
			} else {
				System.out.println("File not created ");
			}
			FileWriter fw = new FileWriter(file, false);
			fw.append('c');
//			fw.flush();
			fw.append('d');
			fw.flush();
			fw.close();
//			for(;;) {
//				System.out.println("inside for");
//			}
			
			FileWriter fw1 = new FileWriter(file, true);
			BufferedWriter bw = new BufferedWriter(fw1);
			bw.write("This is Vijay");
			bw.newLine();
			
			bw.flush();
			bw.close();
			
			FileReader fr = new FileReader(file);
			BufferedReader br = new BufferedReader(fr);
			String line = br.readLine();
			System.out.println(line);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		Object obj = (Object) file;
		
		
	}
}
